<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="../lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
<title>猪类销售统计</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 报表统计 <span class="c-gray en">&gt;</span> 猪类销售统计 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-l"> 日期范围：
		<input type="text" onfocus="WdatePicker({isShowClear:true,readOnly:true,maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({isShowClear:true,readOnly:true,minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" class="input-text" style="width:200px" placeholder="输入客户名称" id="parname" name="parname">
		<button type="submit" class="btn btn-primary radius" id="query" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
		<button type="submit" class="btn btn-primary radius" id="exportExcel" name=""><i class="Hui-iconfont">&#xe644;</i> 导出</button>
		<form id="exportForm" action="/excel/export/exportToPigSeal.do" method="post" class="hidden">
			<input type="hidden" name="exportData" />
		</form>
		<button type="submit" class="btn btn-primary radius" id="print" name=""><i class="Hui-iconfont">&#xe640;</i> 打印</button>
	</div>
	<div id="printTab" class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr><th class="text-c" colspan="14">猪类销售统计表</th></tr>
			<tr class="text-c">
				<th width="200">合作商</th>
				<th width="200">交易时间</th>
				<th width="200">交易员工</th>
				<th width="200">数量</th>
				<th width="200">重量</th>
				<th width="200">金额</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	</div>
</div>
<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="../MyJs/date_string.js"></script> 
<script type="text/javascript" src="../MyJs/tableExport.js"></script> 
<script type="text/javascript" src="../MyJs/jquery.base64.js"></script> 
<script type="text/javascript" src="../lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="../lib/jquery.printArea/jquery.PrintArea.min.js"></script>
<script type="text/javascript">
$(function(){
    var exportData = null;

	$("#print").click(function(){
		$("#printTab").printArea();
	});
	
	$("#exportExcel").click(function(){
		layer.confirm('确认要导出Excel文件吗？',function(index){
            var value = JSON.stringify(exportData);
            $("input[name=exportData]").val(value);
            $("#exportForm").submit();
            layer.msg('下载文件!',{icon:1,time:1000});
		});
	});
	
	$("#query").click(function(){
		getCountPig();
	});
	
	getCountPig();
	
	function getCountPig(){
		$.post("/count/getPigSellCountByDate.do",{datemin:$("#datemin").val(),datemax:$("#datemax").val(),"parname":$("#parname").val()},function(data){
			$(".table>tbody").empty();
			var totalNum = 0;
			var totalWeight = 0;
			var totalMoney = 0;
			$(data).each(function(i,v){
				var $tr = "<tr class='text-c'>" +
						  "<td>"+v.par_name+"</td>" +
						  "<td>"+v.order_date+"</td>" +
						  "<td>"+v.emp_name+"</td>" +
						  "<td>"+v.pig_num+"</td>" +
						  "<td>"+(v.sum_weight).toFixed(2)+"</td>" +
						  "<td>"+(v.order_sub).toFixed(2)+"</td>" +
						  "</tr>";
				totalNum += v.pig_num;
				totalWeight += v.sum_weight;
				totalMoney += v.order_sub;
				$(".table>tbody").append($tr);
			});
            exportData = data;
			$(".table>tbody").append("<tr class='text-c'><td>总计</td><td></td><td></td><td>"+totalNum+"</td><td>"+totalWeight.toFixed(2)+"</td><td>"+totalMoney.toFixed(2)+"</td>");
		},"json");
	}
});
</script> 
</body>
</html>